/*
 * SudokuSolver.h
 *
 *  Created on: Sep 28, 2009
 *      Author: Cha
 */

#include "Sudoku.h"
#include "PriQueue.h"

#ifndef SUDOKUSOLVER_H_
#define SUDOKUSOLVER_H_

struct gridHolder{
	sudokuGrid *space;
	gridHolder *prev;
	gridHolder *next;
};

//used for stacks and queues, basically to keep track
//of what gridHolder to inspect
struct DataStructElem{
	gridHolder *grid;
	DataStructElem *prev;
	DataStructElem *next;
};

class SudokuSolver{
public:
	SudokuSolver(int);
	void initAdjList();
	void DFSSolver(int);
	void printAdjList();
	void printBoardState(); //move this to private eventually
private:
	gridHolder **adj_list;
	Sudoku game;

	DataStructElem *stack_top;
	DataStructElem *queue_front;

	//general solver functions
	void initAdjListElem(gridHolder *, int);
	void findNeighbors();
	void addNeighbor(gridHolder *, gridHolder *);
	bool isGameSolved();
	gridHolder* getUnfilledGrid();
	bool allDiff(gridHolder *, int);

	//stack functions
	bool stackIsEmpty();
	void pushStack(gridHolder*);
	gridHolder* popStack();
	void printStack();

	//queue functions
	bool queueIsEmpty();
	void enqueue(gridHolder*);
	gridHolder* dequeue();

	void forwardCheck(gridHolder*);
	void restoreNeighbors(gridHolder *, int);
	void fillInPossible();

};


#endif /* SUDOKUSOLVER_H_ */
